home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan 2
/
Opus 5 - Magellan 2.iso
/
Extras
/
D51_NUSource
/
Source
/
DOpusFuncs
/
DOpusFuncs.s
< prev
next >
Wrap
Text File
|
1996-01-06
|
19KB
|
428 lines
*=- PROGRAM INFORMATION -=*************************************************************
* DopusFuncs, ©1996 Leo Davidson *
*=====================================================================================*
* Purpose: Conversion of the DirToDest, ParentToDest, WinCopy and WinSwap scripts. *
* This program does various operations on the paths of the source/dest *
* listers under DOpus5. *
* It (will) also include any _small_ functions which are thought of. *
***************************************************************************************
*=- ASSEMBLE-TIME SWITCHES -=**********************************************************
* Comment out to disable the effect(s) described. *
***************************************************************************************
;Beta_Version ; Include Debug-Labels, Beta messages, etc.
;Beta_Version_ARexx ; Include runtime-info about ARexx messages sent.
DOpus5_Error ; Enable Error messages via DOpus5/"dopus request".
;Test_Pool_On_OS3 ; Force use of non-ROM pool routines, even with OS3+.
;No_Requesters ; Disable all requester-based output.
; All error messages will be sent to shell.
; Will also turn off "Please insert volume XXX" reqs.
Default_Req ; Make requesters the default for error messages.
*=- VERSION INFORMATION -=*************************************************************
* Things like versions numbers, dates, and the name of the program are all defined *
* here as macros to save having to edit the entire source code. *
*=====================================================================================*
* The version strings should conform to the style guide. (Even though I think it *
* isn't the best way to do it, it's a standard :-( ). *
***************************************************************************************
PROGNAM MACRO Program name.
dc.b "DOpusFuncs" /No spaces!/
ENDM
VERSION MACRO The version of the program.
dc.b "1.6" version.revision - /No leading zeros/
ENDM
REVDATE MACRO Date of completion.
dc.b "6.1.96" DD.MM.YY - /No leading zeros/
ENDM
REVDAT2 MACRO Date of completion.
dc.b "06-Jan-1996" /Any format/ (Not in $VER string)
ENDM
*=- ASSEMBLER INFORMATION/OPTIONS -=***************************************************
Section Super_Main,Code Assemble to Public Memory.
IFD Beta_Version -.
Opt D+ |
Opt hcln |_ Debug info ON
ELSE | for Beta Versions.
Opt D- |
ENDC -'
***************************************************************************************
Bra ProgBeg Jump to the start of the program.
***************************************************************************************
VerStr Dc.b "$VER: " -.
PROGNAM |
IFD Beta_Version |
Dc.b "_DEBUG" |
ENDC |_ For 2.0+ Version Command
Dc.b " " | (At the top to make "Version"
ActVer VERSION | find it quicker!)
Dc.b " (" |
REVDATE |
Dc.b ")",0 -'
Even
;=====================================================================================;
; Include Asm:Include/Nudel_Constants.i
;
; include dos/dos.i
; include dos/var.i
; include exec/types.i
; include exec/nodes.i
; include exec/memory.i
; include rexx/storage.i
; include intuition/intuition.i
; include intuition/intuitionbase.i
; include libraries/iffparse.i
;
; include ASM:LVO3.0/dos_lib.i
; include ASM:LVO3.0/exec_lib.i
; include ASM:LVO3.0/intuition_lib.i
; include ASM:LVO3.0/rexxsyslib_lib.i
; include ASM:LVO3.0/utility_lib.i
; include ASM:LVO3.0/iffparse_lib.i
; include ASM:LVO3.0/mathieeedoubbas_lib.i
; include ASM:LVO3.0/graphics_lib.i
Include Nudel_Symbols.gs
***************************************************************************************
* The Variables (Address Equates for Space allocated at program start) *
***************************************************************************************
RSReset
IFND No_Requesters
;=====================================================================================;
N_EasyStruct Equ __RS ;- EasyStruct for EasyRequest ----------------;
;=====================================================================================;
N_ES_Length Rs.l 1 Length of the structure.
N_ES_Flags Rs.l 1 Flags (not currently supported).
N_ES_Title Rs.l 1 Ptr to NullTerm Title Text.
N_ES_Body Rs.l 1 Ptr to NullTerm Body Text.
N_ES_Gadgets Rs.l 1 Prt to Gadget(s) Texts.
N_EasyStruct_Len Equ (__RS)-N_EasyStruct
ENDC
;=====================================================================================;
; Nudel Info-Block Stuff ;
;=====================================================================================;
FakeNIB Rs.b NIB_SizeOf ;- Fake NIB for setting pseudo-filenames -----;
FakeNIB_Adrs Rs.l 1 Address of FakeNIB (saves a few "lea"'s).
Active_NIB Rs.l 1 Ptr to currently "Active" NIB, or null.
Base_NIB Rs.l 1 Ptr to base NIB in linked list, or null.
Last_NIB Rs.l 1 Ptr to last NIB in linked list, or null.
CAction Rs.l 1 Ptr to current "Action" error message.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
BaseDir_NIB Rs.l 1 Ptr to NIB for the Lock() on source-lister dir.
ParentDir_NIB Rs.l 1 Ptr to NIB for the Lock() on the parent dir.
;=====================================================================================;
;=====================================================================================;
; READARGS() STUFF ;
;=====================================================================================;
RDA_Rtn Rs.l 1 Pointer to returned RDArgs structure
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
RDA_Array Equ __RS Array of longwords matching template
RDA_Template Equ *
RexxPort_A Rs.l 1
Dc.b "RP=REXXPORT/A,"
ClipEntry_KM Rs.l 1
Dc.b "CLIPENTRY/K/M,"
DirToDest_S Rs.l 1
Dc.b "DIRTODEST/S,"
ParentToDest_S Rs.l 1
Dc.b "PARENTTODEST/S,"
WinCopy_S Rs.l 1
Dc.b "WINCOPY/S,"
WinSwap_S Rs.l 1
Dc.b "WINSWAP/S,"
NewSource_S Rs.l 1
Dc.b "NEWSOURCE/S,"
SourceDir_K Rs.l 1
Dc.b "SOURCEDIR/K,"
SourcePos_K Rs.l 1
Dc.b "SOURCEPOS/K,"
SourceLock_S Rs.l 1
Dc.b "SOURCELOCK/S,"
NewDest_S Rs.l 1
Dc.b "NEW=NEWDEST/S,"
DestDir_K Rs.l 1
Dc.b "DIR=DESTDIR/K,"
DestPos_K Rs.l 1
Dc.b "POS=DESTPOS/K,"
DestLock_S Rs.l 1
Dc.b "LOCK=DESTLOCK/S,"
NoFront_S Rs.l 1
Dc.b "NOFRONT/S,"
NoNew_S Rs.l 1
Dc.b "NONEW/S"
RDA_Temp_Len Equ *-RDA_Template
Dc.b 0
Even
;=====================================================================================;
; OPEN_LIBRARIES STRUCTURES ;
;=====================================================================================;
LibBases_Start Equ __RS
LibData_Start Equ *
; NOTE: The open_lib_error routine requires lib-versions < 100
N_DOSBase Rs.l 1
DOSName_Ptr Dc.l N_DOSName-LibNames_Start
DOSVers Dc.l 37
N_RexBase Rs.l 1
RexName_Ptr Dc.l N_RexName-LibNames_Start
RexVers Dc.l 0
N_IFFBase Rs.l 1
IFFBase_Ptr Dc.l N_IFFName-LibNames_Start
IFFVers Dc.l 37
IFND No_Requesters
N_IntBase Rs.l 1
IntBase_Ptr Dc.l N_IntName-LibNames_Start
IntVers Dc.l 37
ENDC
LibBases_Finish Equ __RS
NumLibs Equ (LibBases_Finish-LibBases_Start)/4
;-------------------------------------------------------------------------------------;
LibNames_Start Equ *
N_DOSName DOSNAME
N_RexName REXXSYSLIBNAME
N_IFFName IFFPARSENAME
IFND No_Requesters
N_IntName INTNAME Required by Open_Libraries_Error rtn.
ENDC
Even
;=====================================================================================;
; FLAG BYTES ;
;=====================================================================================;
STD_F_1 Rs.b 1 Standard files.
EVEN_F_1 Rs.b 1 (Here as an Even)
;=====================================================================================;
; VARIOUS DATA ;
;=====================================================================================;
DosRtnC Rs.l 1 Return code for DOS. (-> d0 at end)
;=====================================================================================;
; RawDoFmt() Stuff ;
;=====================================================================================;
; IFD DATA_RAWDOFMT
RDF_Size Rs.l 1 Size of RawDoFmt() buffer.
RDF_Adrs Rs.l 1 Address of RawDoFmt() buffer.
RDF_Array Equ __RS
RDF_1_Long Rs.l 1 -.
RDF_2_Long Rs.l 1 |_ DataArray for RawDoFmt()
RDF_3_Long Rs.l 1 | *MUST* *ALL* be *LONGWORDS*
RDF_4_Long Rs.l 1 -'
; ENDC
;=====================================================================================;
; VARIOUS ADDRESS-POINTERS, ETC ;
;=====================================================================================;
StarStk Rs.l 1 Original Stack Pointer.
PoolHead Rs.l 1 Header for program's memory pool.
CLI_Hdl Rs.l 1 Output CLI (or whatever) handle.
NudelPort Rs.l 1 Pointer to our MsgPort.
NudelRexxMsg Rs.l 1 Pointer to our RexxMsg.
CRexxPort Rs.l 1 Ptr to name of current Rexx host to talk to.
NudelIFFHandle Rs.l 1 Pointer to our IFFHandle.
NudelClipboardHandle Rs.l 1 Pointer to out Clipboard Handle (iffparse)
;=====================================================================================;
; Temp Storage and Buffers ;
;=====================================================================================;
Buffer1Len Equ 1024
Buffer1 Rs.b Buffer1Len Buffer for anything
Buffer2Len Equ 1024
Buffer2 Rs.b Buffer2Len Buffer for anything
IFD Beta_Version_ARexx
BufferALen Equ 1024
BufferA Rs.b BufferALen Buffer for ARexx beta messages.
ENDC
Source_HandleLen Equ 42
Source_Handle Rs.b Source_HandleLen
Dest_HandleLen Equ 42
Dest_Handle Rs.b Dest_HandleLen
DirName1BufferLen Equ 80 AmigaDOS limit is 30 chars,
DirName1Buffer Rs.b DirName1BufferLen but maybe OpusFTP w/ UNIX?
PathBuffer1Len Equ 512
PathBuffer1 Rs.b PathBuffer1Len
PathBuffer2Len Equ 512
PathBuffer2 Rs.b PathBuffer2Len
Temp001 Rs.l 1 -._ For temp storage
Temp002 Rs.l 1 -' in routines.
;=====================================================================================;
NULLEND Equ __RS ;- Overlays Start Here -----------------------;
;=====================================================================================;
;=====================================================================================;
LENVARS Equ __RS ;- End of variables/overlays -----------------;
;=====================================================================================;
*=- MAIN PROGRAM -=********************************************************************
* Calls the subroutines. *
***************************************************************************************
ProgBeg Bsr.s Setup Allocate Mem and initialize stuff.
Bsr NewSource Open a new Source lister, if required.
Bsr NewDest Open a new Destination lister, if required.
Bsr ClipEntry -.
Bsr DirToDest |
Bsr ParentToDest |- Perform the
Bsr WinCopy | requested action(s)
Bsr WinSwap -'
Bra Finish Close/Deallocate everything and exit.
*=- SETUP -=***************************************************************************
* Allocate Memory, Open Libraries, Parse Commandline, etc *
* This MUST be the first Subroutine run. *
***************************************************************************************
Setup Move.l #MEMF_PUBLIC!MEMF_CLEAR,d0 Public, Cleared mem.
Move.l #5120,d1 Puddle size = 5k.
Move.l #5120,d2 Thresh size = Puddle size.
Bsr AsmCreatePool Create this prog's mem pool.
Move.l a0,-(SP) Preserve PoolHeader
Bne.s SGotMm1 -.
Addq.l #4,a7 |_ If Allocation failed, Quick Exit.
Moveq #RETURN_FAIL,d0 | pool and do a quick exit.
RTS -'
SGotMm1 Move.l #LENVARS,d0 Size of variables' memory
;;;;;;; Move.l a0,a0 PoolHeader to a0 for allocation.
Bsr AsmAllocPooled Allocate for the variables.
Move.l (SP)+,a0 Restore PoolHeader
Move.l d0,a5 Put variable/overlay address into A5
Tst.l d0 (Moves to a? don't set CCR).
Bne.s SGotMm2 -.
Bsr AsmDeletePool |
Addq.l #4,a7 |- If Allocation failed, delete the
Moveq #RETURN_FAIL,d0 | pool and do a quick exit.
RTS -'
SGotMm2 Move.l a0,PoolHead(a5) Store header of memory pool.
Lea FakeNIB(a5),a0 -._ Store address of FakeNIB(a5)
Move.l a0,FakeNIB_Adrs(a5) -' for quick access later.
Move.l #RETURN_OK,DosRtnC(a5) Default DOS return code: "OK".
IFD LENOVER
Lea NULLEND(a5),a0 -.
Lea Over01(pc),a1 | Copy Overlay
Move.l #(LENOVER/2)-1,d0 |- Backings onto
OverPrL Move.w (a1)+,(a0)+ | Overlay Space (word moves)
DBra d0,OverPrL -'
ENDC
;=====================================================================================;
Move.l a7,StarStk(a5) Store Stack Pointer
Addq.l #4,StarStk(a5) Compensate for this being a subrout.
IFND No_Requesters
SetReqDefault Set default to requester/shell.
ENDC
Bsr Open_Libraries Open libraries.
N_CallDOS Output -._ Get output Handle
Move.l d0,CLI_Hdl(a5) -' (CLI window or whatever)
;;;;;;; Setup any non-zero default values for switch options here (below).
Bsr RArgNor Parse the commandline with ReadArgs
;=====================================================================================;
Tst.l NoNew_S(a5)
Bne.s NoNew_S_Skip
BSet #SF1_NewListers,STD_F_1(a5) Get(Source|Dest)Handle: Allow new listers
NoNew_S_Skip
Move.l RexxPort_A(a5),CRexxPort(a5) RexxPort from CommandLine.
Bra.s CreateNudelPort Create our MsgPort.
;;;;;;; RTS for us.
*=- FINISH -=**************************************************************************
* Close Everything Down, Return Memory Etc to System and End Program *
*=====================================================================================*
* All routines in this section MUST make sure that what they are about to free back *
* to the system has actually been taken in the first place! (With the exception of *
* the Main-Variable memory: if this could not be allocated the program will have *
* quit without calling Finish.) *
*=====================================================================================*
* The Finish routine may be called from sub-routines at any level because the *
* original stack-pointer is restored so that RTS always quits the prog. *
***************************************************************************************
Finish
IFD Beta_Version
Bsr_ErrorN ErrAct_FinishBetaMsg(pc),#0
ENDC
Bsr CloseNudelIFF Close our IFFhandle.
Bsr FreeNudelIFF Free our IFFHandle.
Bsr CloseNudelClipboard Close the Clipboard.
Bsr DeleteNudelRexxMsg Delete our RexxMsg (also clears arguments).
Bsr.s DeleteNudelPort Delete our MsgPort.
Bsr NIBs_DeleteAll Delete all Nudel-Info-Blocks.
Bsr FArgNor Free the commandline related memory.
Bsr Close_Libraries Close all open libraries.
Move.l StarStk(a5),a7 Ignore all Branches.
Move.l DosRtnC(a5),-(SP) Store DOS return code...
Bsr LeoDeletePool Free the entire memory pool.
Move.l (SP)+,d0 Return code to d0 for DOS.
RTS End Program
IFD Beta_Version
ErrAct_FinishBetaMsg
Dc.b "Finish routine run",0
Even
ENDC
*=- EXTERNAL SUB-ROUTINES -=***********************************************************
* Sub-routines stored in external "library" files. *
***************************************************************************************
;=====================================================================================;
; OS Subroutines. ;
;=====================================================================================;
SYS_CLIRITE ; Write text using CLI_Hdl(a5) as output handle.
SYS_READARG ; ReadArgs() routine.
SYS_FREEARG ; FreeArgs() routine.
SYS_CHKCRTC ; Check for ^C-Break and abort program if sent.
SYS_PORTS ; CreateMsgPort(), DeleteMsgPort() routines.
Include ASM:Source/Routines/System.s
;=====================================================================================;
; Data Subroutines. (Number/String Handling, etc etc) ;
;=====================================================================================;
DATA_NULLLEN ; Calculate the length of a Null-Term String.
DATA_JOINNT ; Join two null-terminated strings.
DATA_JOINARRAY ; Join together an array of strings.
DATA_COPYCN3 ; Copy chars with Null-Term, don't copy Null, no Length
DATA_CHARCNT ; Copy x chars with Null-Term
DATA_CHARCOPNL ; Copy x chars with Null-Term and specified terminator.
DATA_NUM2ASC ; Raw Number to ASCII conversion.
DATA_RAWDOFMT ; RawDoFmt() routine.
Include ASM:Source/Routines/Data.s
;=====================================================================================;
; NudelInfoBlock Subroutines. ;
;=====================================================================================;
NIBR_UNLOCK ; DOS/UnLock
NIBR_LOCK ; DOS/Lock
Include ASM:Source/Routines/NIB.s
;=====================================================================================;
; Directory Opus 5 Subroutines. ;
;=====================================================================================;
DO5_GetSource ; Get first source handle.
DO5_GetDest ; Get first destination handle.
DO5_GetPath ; Get the path of a lister.
DO5_GetFSelDir ; Get first selected directory in a lister.
;DO5_GetFSelEnt ; Get first selected entry in a lister.
DO5_SetPath ; Set (read) a new path into a lister.
DO5_Refesh ; Refresh a lister.
DO5_Select ; (De)select a lister entry.
DO5_NewLister ; Open a new lister.
DO5_ListerSet ; Generic "Lister Set..." command.
DO5_GenError ; Error message for things which really shouldn't go wrong.
DO5_CopyLister ; Copy a lister.
DO5_ListerWait ; Wait for a lister to finish what it's doing.
DO5_DOpusFront ; Move the DOpus screen to the front, unless "NoFront/S"
Include ASM:Source/Routines/DOpus5_ARexx.s
;=====================================================================================;
; Other routines. ;
;=====================================================================================;
Include ASM:Source/Routines/ARexx.s
Include ASM:Source/Routines/Pool.s
Include ASM:Source/Routines/OpenLibraries.s
Include Asm:Source/Routines/Clipboard.s
***************************************************************************************
Include ASM:Source/DOpusFuncs/NewLister.s
Include ASM:Source/DOpusFuncs/ClipEntry.s
Include ASM:Source/DOpusFuncs/DirToDest.s
Include ASM:Source/DOpusFuncs/ParentToDest.s
Include ASM:Source/DOpusFuncs/WinCopy.s
Include ASM:Source/DOpusFuncs/WinSwap.s